/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package com.stip.server.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author BlueBerry
 */
@Entity
@Table(name = "dorm")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dorm.findAll", query = "SELECT d FROM Dorm d"),
    @NamedQuery(name = "Dorm.findById", query = "SELECT d FROM Dorm d WHERE d.id = :id"),
    @NamedQuery(name = "Dorm.findByDormName", query = "SELECT d FROM Dorm d WHERE d.dormName = :dormName")})
public class Dorm implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 50)
    @Column(name = "dorm_name")
    private String dormName;
    @OneToMany(mappedBy = "dorm")
    private List<UsersInfo> usersInfoList;

    public Dorm() {
    }

    public Dorm(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDormName() {
        return dormName;
    }

    public void setDormName(String dormName) {
        this.dormName = dormName;
    }

    @XmlTransient
    public List<UsersInfo> getUsersInfoList() {
        return usersInfoList;
    }

    public void setUsersInfoList(List<UsersInfo> usersInfoList) {
        this.usersInfoList = usersInfoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dorm)) {
            return false;
        }
        Dorm other = (Dorm) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.stip.server.entities.Dorm[ id=" + id + " ]";
    }
    
}
